var express = require('express');
var router = express.Router();

const db = require('../public/javascripts/db')

router.put('/', function(req, res, next) {
    
    let info = req.body;
    let sql = "update staff set staff_name=?, staff_pass=?, staff_tel=?, staff_status=? where staff_id=?";
    let data = [info.staff_name, info.staff_pass, info.staff_tel, info.staff_status, info.staff_id];

    db(sql, data, (result) => {
        if(result.affectedRows == 1){
            res.json({
                code: 200,
                messages: "用户信息修改成功"
            })
        }else{
            res.json({
                code: 500,
                messages: "服务器错误"
            })
        }
    })

});

module.exports = router;
